﻿function CheckInput(dom) {
    //debugger;
    var inputList = $("#" + dom + "").find("input[type='text'],input[type='number']");
    for (var i = 0; i < inputList.length; i++) {
        if ($(inputList[i]).val() == '') {
            return false;
        }
    }
    return true;
}
//时间戳转日期
function formatDate(timeStamp) {
    //  debugger;
    if (timeStamp != ""&& timeStamp != null){
        var date = parseInt(timeStamp.substr(6, 13));
        return new Date(date).toLocaleDateString();
    } else {
        return "";
    }
}

function formatDateTime(timeStamp) {
    //debugger;
    if (timeStamp != "" &&timeStamp != null)
    {
    var date = parseInt(timeStamp.substr(6, 13));
    var date1 = new Date(date);
    Y = date1.getFullYear() + '-';
    M = (date1.getMonth() + 1 < 10 ? '0' + (date1.getMonth() + 1) : date1.getMonth() + 1) + '-';
    D = date1.getDate() < 10 ? '0' + (date1.getDate()) + ' ' : date1.getDate() + ' ';
    h = date1.getHours() + ':';
    m = date1.getMinutes() + ':';
    s = date1.getSeconds();
    return Y+M+D+h+m+s;
    } else {
        return "";
    }
}

function subString(str) {
    //debugger;
    var result = '';
    if (str.length > 6) {
        result = str.substr(0, 6) + "...";
    } else {
        result = str;
    }
    return result;
}

function blockMean(menuname) {
    var div = $("#accordion div");
    for (var i = 0; i < div.length; i++) {
        if ($(div[i]).text() == menuname) {
            $(div[i]).next().css("display", "block");
        }
    }
}

(function ($) {
    $.fn.extend({
        fileTypeJudge: function (str) {
            return this.each(function () {
                var rightFileType;
                var fileType;
                var pojo;
                if (str == "photo") {
                    rightFileType = new Array("jpg", "bmp", "gif", "png", "jpeg");
                    pojo = "图片";
                } else if (str == "txt") {
                    rightFileType = new Array("txt");
                    pojo = "txt文件";
                } else if (str == "wav") {
                    rightFileType = new Array("wav");
                    pojo = "wav格式语音文件";
                } else {
                    rightFileType = new Array("word", "xlsx", "ppt");
                    pojo = "office文件";
                }
                var fileType = $(this).val().substring($(this).val().lastIndexOf(".") + 1);
                if (!in_array(fileType, rightFileType)) {
                    this.outerHTML += '';
                    this.value = "";
                    layer.msg("只支持" + pojo + "文件上传！");
                }
            });
        }
    });
})(jQuery);

function in_array(needle, haystack) {
    // 得到needle的类型  
    var type = typeof needle;
    if (type == 'string' || type == 'number') {
        for (var i in haystack) {
            if (haystack[i] == needle) {
                return true;
            }
        }
    }
    return false;
}

